home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / JFC.bin / MultiTreeUI.java < prev    next >
Text File  |  1998-06-30  |  7KB  |  231 lines

  1. /*
  2.  * @(#)MultiTreeUI.java    1.17 98/02/02
  3.  * 
  4.  * Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  * 
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  * 
  19.  */
  20.  
  21. package com.sun.java.swing.plaf.multi;
  22.  
  23. import java.util.Vector;
  24. import java.io.Serializable;
  25. import com.sun.java.swing.*;
  26. import java.awt.*;
  27. import com.sun.java.swing.plaf.*;
  28. import com.sun.java.swing.tree.*;
  29.  
  30. /**
  31.  * MultiTreeUI implementation
  32.  * <p>
  33.  * Warning: serialized objects of this class will not be compatible with
  34.  * future swing releases.  The current serialization support is appropriate
  35.  * for short term storage or RMI between Swing1.0 applications.  It will
  36.  * not be possible to load serialized Swing1.0 objects with future releases
  37.  * of Swing.  The JDK1.2 release of Swing will be the compatibility
  38.  * baseline for the serialized form of Swing objects.
  39.  *
  40.  * @version 1.17 02/02/98
  41.  * @author Willie Walker
  42.  */
  43. public class MultiTreeUI extends TreeUI
  44.     implements Serializable {
  45.  
  46.     /**
  47.      * The Vector containing the real UI's.  This is populated 
  48.      * in the call to createUI, and can be obtained by calling
  49.      * getUIs.  The first element is guaranteed to the real UI 
  50.      * obtained from the default look and feel.
  51.      */
  52.     protected Vector uis = new Vector();
  53.  
  54. ////////////////////
  55. // Common UI methods
  56. ////////////////////
  57.  
  58.     public static ComponentUI createUI(JComponent c) {
  59.         ComponentUI mui = new MultiTreeUI();
  60.         return MultiLookAndFeel.createUIs(mui,
  61.                                           ((MultiTreeUI) mui).uis,
  62.                                           c);
  63.     }
  64.  
  65.     /**
  66.      * Return the list of UI's associated with this multiplexing UI.  This 
  67.      * allows processing of the UI's by an application aware of multiplexing 
  68.      * UI's on components.
  69.      */
  70.     public ComponentUI[] getUIs() {
  71.         return MultiLookAndFeel.uisToArray(uis);
  72.     }
  73.  
  74. //////////////////////
  75. // ComponentUI methods
  76. //////////////////////
  77.  
  78.     public void installUI(JComponent c) {
  79.         for (int i = 0; i < uis.size(); i++) {
  80.             ((ComponentUI) (uis.elementAt(i))).installUI(c);
  81.         }
  82.     }
  83.  
  84.     public void uninstallUI(JComponent c) {
  85.         for (int i = 0; i < uis.size(); i++) {
  86.             ((ComponentUI) (uis.elementAt(i))).uninstallUI(c);
  87.         }
  88.     }
  89.   
  90.     public void paint(Graphics g, JComponent c) {
  91.         for (int i = 0; i < uis.size(); i++) {
  92.             ((ComponentUI) (uis.elementAt(i))).paint(g,c);
  93.         }
  94.     }
  95.       
  96.     public void update(Graphics g, JComponent c) {
  97.         for (int i = 0; i < uis.size(); i++) {
  98.             ((ComponentUI) (uis.elementAt(i))).update(g,c);
  99.         }
  100.     }
  101.  
  102.     public Dimension getPreferredSize(JComponent c) {
  103.         return ((ComponentUI) (uis.elementAt(0))).getPreferredSize(c);
  104.     }
  105.  
  106.     public Dimension getMinimumSize(JComponent c) {
  107.         return ((ComponentUI) (uis.elementAt(0))).getMinimumSize(c);
  108.     }
  109.  
  110.     public Dimension getMaximumSize(JComponent c) {
  111.         return ((ComponentUI) (uis.elementAt(0))).getMaximumSize(c);
  112.     }
  113.  
  114.     public boolean contains(JComponent c, int x, int y) {
  115.         return ((ComponentUI) (uis.elementAt(0))).contains(c,x,y);
  116.     }
  117.  
  118. /////////////////
  119. // TreeUI Methods
  120. /////////////////
  121.  
  122.     public int getRowCount() {
  123.         return ((TreeUI) (uis.elementAt(0))).getRowCount();
  124.     }
  125.  
  126.     public boolean isExpanded(TreePath path) {
  127.         return ((TreeUI) (uis.elementAt(0))).isExpanded(path);
  128.     }
  129.  
  130.     public boolean isExpanded(int row) {
  131.         return ((TreeUI) (uis.elementAt(0))).isExpanded(row);
  132.     }
  133.  
  134.     public boolean isCollapsed(TreePath path) {
  135.         return ((TreeUI) (uis.elementAt(0))).isCollapsed(path);
  136.     }
  137.  
  138.     public boolean isCollapsed(int row) {
  139.         return ((TreeUI) (uis.elementAt(0))).isCollapsed(row);
  140.     }
  141.  
  142.     public void makeVisible(TreePath path) {
  143.         for (int i = 0; i < uis.size(); i++) {
  144.             ((TreeUI) (uis.elementAt(i))).makeVisible(path);
  145.         }
  146.     }
  147.     
  148.     public boolean isVisible(TreePath path) {
  149.         return ((TreeUI) (uis.elementAt(0))).isVisible(path);
  150.     }
  151.  
  152.     public Rectangle getPathBounds(TreePath path) {
  153.         return ((TreeUI) (uis.elementAt(0))).getPathBounds(path);
  154.     }
  155.  
  156.     public Rectangle getRowBounds(int row) {
  157.         return ((TreeUI) (uis.elementAt(0))).getRowBounds(row);
  158.     }
  159.  
  160.     public void scrollPathToVisible(TreePath path) {
  161.         for (int i = 0; i < uis.size(); i++) {
  162.             ((TreeUI) (uis.elementAt(i))).scrollPathToVisible(path);
  163.         }
  164.     }
  165.  
  166.     public void scrollRowToVisible(int row) {
  167.         for (int i = 0; i < uis.size(); i++) {
  168.             ((TreeUI) (uis.elementAt(i))).scrollRowToVisible(row);
  169.         }
  170.     }
  171.  
  172.     public TreePath getPathForRow(int row) {
  173.         return ((TreeUI) (uis.elementAt(0))).getPathForRow(row);
  174.     }
  175.  
  176.     public int getRowForPath(TreePath path) {
  177.         return ((TreeUI) (uis.elementAt(0))).getRowForPath(path);
  178.     }
  179.  
  180.     public void expandPath(TreePath path) {
  181.         for (int i = 0; i < uis.size(); i++) {
  182.             ((TreeUI) (uis.elementAt(i))).expandPath(path);
  183.         }
  184.     }
  185.  
  186.     public void expandRow(int row) {
  187.         for (int i = 0; i < uis.size(); i++) {
  188.             ((TreeUI) (uis.elementAt(i))).expandRow(row);
  189.         }
  190.     }
  191.  
  192.     public void collapsePath(TreePath path) {
  193.         for (int i = 0; i < uis.size(); i++) {
  194.             ((TreeUI) (uis.elementAt(i))).collapsePath(path);
  195.         }
  196.     }
  197.  
  198.     public void collapseRow(int row) {
  199.         for (int i = 0; i < uis.size(); i++) {
  200.             ((TreeUI) (uis.elementAt(i))).collapseRow(row);
  201.         }
  202.     }
  203.  
  204.     public TreePath getClosestPathForLocation(int x, int y) {
  205.         return ((TreeUI) (uis.elementAt(0))).getClosestPathForLocation(x, y);
  206.     }
  207.  
  208.     public int getClosestRowForLocation(int x, int y) {
  209.         return ((TreeUI) (uis.elementAt(0))).getClosestRowForLocation(x, y);
  210.     }
  211.  
  212.     public boolean isEditing() {
  213.         return ((TreeUI) (uis.elementAt(0))).isEditing();
  214.     }
  215.  
  216.     public boolean stopEditing() {
  217.         return ((TreeUI) (uis.elementAt(0))).stopEditing();
  218.     }
  219.  
  220.     public void startEditingAtPath(TreePath path) {
  221.         for (int i = 0; i < uis.size(); i++) {
  222.             ((TreeUI) (uis.elementAt(i))).startEditingAtPath(path);
  223.         }
  224.     }
  225.  
  226.     public TreePath getEditingPath() {
  227.         return ((TreeUI) (uis.elementAt(0))).getEditingPath();
  228.     }
  229. }
  230.  
  231.